package l2ft.gameserver.model.entity.events.impl;

import java.util.Calendar;

import l2ft.commons.collections.MultiValueSet;
import l2ft.gameserver.Announcements;
import l2ft.gameserver.model.entity.events.GlobalEvent;

public class March8Event extends GlobalEvent
{
	private Calendar _calendar = Calendar.getInstance();
	private static final long LENGTH = 7 * 24 * 60 * 60 * 1000L;

	public March8Event(MultiValueSet<String> set)
	{
		super(set);
	}

	/**
	 * ?????????? ??? ?????? ???????, ???? ??????? ????? ?????? ????
	 */
	@Override
	public void initEvent()
	{
		if(false)
			super.initEvent();
	}

	@Override
	public void startEvent()
	{
		super.startEvent();

		Announcements.getInstance().announceToAll("Test startEvent");
	}

	@Override
	public void stopEvent()
	{
		super.stopEvent();

		Announcements.getInstance().announceToAll("Test stopEvent");
	}

	@Override
	public void reCalcNextTime(boolean onInit)
	{
		clearActions(); // ??????? ??? ???????? ??????? ????????(?????? ?? ???????, ??? ??? ?????? ???? ??? ??????????)

		// ?????????? ??? ??????, ??????? ????, ???? ??? ??? ???????????? ???????? 1 ???
		if(onInit)
		{
			_calendar.set(Calendar.MONTH, Calendar.MARCH);
			_calendar.set(Calendar.DAY_OF_MONTH, 8);
			_calendar.set(Calendar.HOUR_OF_DAY, 0);
			_calendar.set(Calendar.MINUTE, 0);
			_calendar.set(Calendar.SECOND, 0);

			if((_calendar.getTimeInMillis() + LENGTH) < System.currentTimeMillis())
				_calendar.add(Calendar.YEAR, 1);
		}
		// ???? ??????? ?? ??????? ??????? - ????????? ???
		else
			_calendar.add(Calendar.YEAR, 1);

		registerActions(); // ???????????? ????????
	}

	@Override
	protected long startTimeMillis()
	{
		return _calendar.getTimeInMillis();
	}
}
